<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // lastIndoxOf() 数组从后往前数，找到第一个符合条件的元素的索引号
        let arr = ['a', 'b', 'b', 'v', 'a', 'c', 'b', 'asd'];
        last = 'a';
        function lastindexOf2(arr, a) {
            for (let i = arr.length; i > 0; i--) {
                if (arr[i] == a) {
                    return arr.length - 1 - i;//总长-1，索引值-i,为现在的索引号
                }
            }
            return -1; 
        }
        console.log(lastindexOf2(arr, last));
    </script>
</body>

</html>